package com.itheima.streamdemo.mystream;

import java.util.ArrayList;
import java.util.Collections;

public class MyStream1 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"张三丰","张无忌","张翠山","王林","张良","谢广坤");

        //filter方法中必须传递一个判断语句,未来符合条件的数据会保留下来
        //不符合条件的数据会从流中被清除
        //filter方法底层会自动遍历流中的数据,将每个数据依次赋值给s
        list.stream().filter(s->s.startsWith("张"))
                .filter(s->s.length() == 3)
                .forEach(s-> System.out.println(s));
    }
}
